package com.qkjia.day01;

import java.util.*;

public class Test09_NotSafe {
    public static void main(String[] args) {
        //线程不安全
        //List<String> list = new ArrayList<>();
        List<String> list = Collections.synchronizedList(new ArrayList<>());
        //线程安全
        //List<String> list = new Vector<>();
        for (int i = 0; i <100 ; i++) {
            new Thread(()->{
                list.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(list);
            },""+i).start();
        }
    }
}
